<!DOCTYPE html>
<meta charset="UTF-8">
<a href="#" data-type="linkbutton" onclick="getSelected()" data-define="'width':180">获得选择的单行</a>
<a href="#" data-type="linkbutton" onclick="getSelections()" data-define="'width':180">获得选择的多行</a>
<table id="dg_selection" data-type="grid" title="gird选择框演示"
	data-define="singleSelect:true,
		method:'get',url: '${rc.contextPath}/assets/ui/jww/demo/testdata/grid_data1.json',
		fitColumns:true
		">
	<thead>
		<tr>
			<th data-define="field:'itemid',width:80,checkbox:false">ID</th>
			<th data-define="field:'productid',width:200">产品名称</th>
			<th data-define="field:'listprice',width:80,align:'right'">成本</th>
			<th data-define="field:'unitcost',width:80,align:'right'">单价</th>
			<th data-define="field:'attr1',width:100">属性</th>
			<th data-define="field:'status',width:60,align:'center'">状态</th>
		</tr>
	</thead>
</table>
<div style="margin: 10px 0;">
	<span>选择模式: </span> <select onchange="$('#dg_selection').grid({singleSelect:(this.value==0)})">
		<option value="0">单选</option>
		<option value="1">多选</option>
	</select>
</div>
<script type="text/javascript">
    function getSelected() {
	    var row = $('#dg_selection').grid('getSelected');
	    if (row) {
		    $.messager.alert('Info', row.itemid + ":" + row.productid + ":" + row.attr1);
	    }
    }
    function getSelections() {
	    var ss = [];
	    var rows = $('#dg_selection').grid('getSelections');
	    for ( var i = 0; i < rows.length; i++) {
		    var row = rows[i];
		    ss.push('<span>' + row.itemid + ":" + row.productid + ":" + row.attr1 + '</span>');
	    }
	    $.messager.alert('Info', ss.join('<br/>'));
    }
</script>
